#!usr/bin/env python  
#@time: 2018/01/22 
import threading

#创建全局ThreadLocal对象
local_school = threading.local()

def process_student():
    #获取当前线程关联的student
    std = local_school.student
    print('Hello, %s (in %s)' %(std, threading.current_thread().name))

def process_thread(name):
    #绑定ThreadLocal的student
    local_school.student = name
    process_student()

stu1 = threading.Thread(target=process_thread, args=('Simon',), name='Thread-A')
stu2 = threading.Thread(target=process_thread, args=('Bob',), name='Thread-B')

stu1.start()
stu2.start()

stu1.join()
stu2.join()